<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en_US" xmlns="http://www.w3.org/1999/xhtml" lang="en_US"><head>



  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- deployment.qdoc -->
  <title>Qt 4.7.0: Deploying an Application on Windows</title>
  <link rel="stylesheet" type="text/css" href="deployment-windows_files/style.css">
  <script src="deployment-windows_files/jquery.js" type="text/javascript"></script>
  <script src="deployment-windows_files/functions.js" type="text/javascript"></script>
  <script src="deployment-windows_files/superfish.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="deployment-windows_files/superfish.css">  <script src="deployment-windows_files/narrow.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="deployment-windows_files/narrow.css">
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->
</head><body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="http://doc.qt.nokia.com/4.7/index.html">Home</a></div>
    <a href="http://doc.qt.nokia.com/4.7/index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.nokia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://developer.qt.nokia.com/">DEV</a></li>
        <li class="nav-topright-labs"><a href="http://labs.qt.nokia.com/blogs/">LABS</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://doc.qt.nokia.com/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.nokia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="http://doc.qt.nokia.com/4.7/index.html">Qt 4.7</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://doc.qt.nokia.com/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu sf-js-enabled sf-shadow" id="narrowmenu"> 
		 <li><a href="#">API Lookup</a> 
			 <ul id="topmenuLook"> 
			   <li><a href="http://doc.qt.nokia.com/4.7/classes.html">Class index</a></li> 
 			  <li><a href="http://doc.qt.nokia.com/4.7/functions.html">Function index</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/modules.html">Modules</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/namespaces.html">Namespaces</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/qtglobal.html">Global Declarations</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/licensing.html">Licenses and Credits</a></li> 
			   </ul> 
		 </li> 
		 <li><a href="#">Qt Topics</a> 
			 <ul id="topmenuTopic"> 
			   <li><a href="http://doc.qt.nokia.com/4.7/qt-basic-concepts.html">Programming with Qt</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/qtquick.html">Device UI's &amp; Qt Quick</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/qt-gui-concepts.html">UI Design with Qt</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/developing-with-qt.html">Cross-platform and Platform-specific</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/platform-specific.html">Platform-specific info</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/technology-apis.html">Qt and Key Technologies</a></li> 
			   <li><a href="http://doc.qt.nokia.com/4.7/best-practices.html">How-To's and Best Practices</a></li> 
			 </ul> 
		</li> 
		 <li><a href="#">Examples</a> 
			 <ul id="topmenuexample"> 
				 <li><a href="http://doc.qt.nokia.com/4.7/all-examples.html">Examples</a></li> 
				 <li><a href="http://doc.qt.nokia.com/4.7/tutorials.html">Tutorials</a></li> 
				 <li><a href="http://doc.qt.nokia.com/4.7/demos.html">Demos</a></li> 
				 <li><a href="http://doc.qt.nokia.com/4.7/qdeclarativeexamples.html">QML Examples</a></li> 
			 </ul> 
		 </li> 
 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input name="searchstring" id="pageType" type="text">
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div id="list001" class="list">
          <ul id="ul001">
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/classes.html">Class index</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/functions.html">Function index</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/modules.html">Modules</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/namespaces.html">Namespaces</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qtglobal.html">Global Declarations</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002">
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qt-basic-concepts.html">Programming with Qt</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qtquick.html">Device UI's &amp; Qt Quick</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qt-gui-concepts.html">UI Design with Qt</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/developing-with-qt.html">Cross-platform and Platform-specific</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/platform-specific.html">Platform-specific info</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/technology-apis.html">Qt and Key Technologies</a></li> 
			   <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/all-examples.html">Examples</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/tutorials.html">Tutorials</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/demos.html">Demos</a></li>
              <li style="display: block;" class="defaultLink"><a href="http://doc.qt.nokia.com/4.7/qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="http://doc.qt.nokia.com/4.7/index.html">Home</a></li>
              <!--  Bread crumbs goes here -->
              <li>Deploying an Application on Windows</li>            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#static-linking">Static Linking</a></li>
<li class="level2"><a href="#building-qt-statically">Building Qt Statically</a></li>
<li class="level2"><a href="#linking-the-application-to-the-static-version-of-qt">Linking the Application to the Static Version of Qt</a></li>
<li class="level1"><a href="#shared-libraries">Shared Libraries</a></li>
<li class="level2"><a href="#building-qt-as-a-shared-library">Building Qt as a Shared Library</a></li>
<li class="level2"><a href="#linking-the-application-to-qt-as-a-shared-library">Linking the Application to Qt as a Shared Library</a></li>
<li class="level2"><a href="#creating-the-application-package">Creating the Application Package</a></li>
<li class="level2"><a href="#visual-studio-2005-onwards">Visual Studio 2005 Onwards</a></li>
<li class="level2"><a href="#visual-studio-2008-and-manual-installs">Visual Studio 2008 And Manual Installs</a></li>
<li class="level1"><a href="#application-dependencies">Application Dependencies</a></li>
<li class="level2"><a href="#additional-libraries">Additional Libraries</a></li>
<li class="level2"><a href="#qt-plugins">Qt Plugins</a></li>
<li class="level1"><a href="#related-third-party-resources">Related Third Party Resources</a></li>
</ul>
</div>
<h1 class="title">Deploying an Application on Windows</h1>
<span class="subtitle"></span>
<!-- $$$deployment-windows.html-description -->
<div class="descr"> <a name="details"></a>
<p>This documentation will describe how to determine which files you 
should include in your distribution, and how to make sure that the 
application will find them at run-time. We will demonstrate the 
procedures in terms of deploying the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> application that is provided in Qt's examples directory.</p>
<p>Contents:</p>
<a name="static-linking"></a>
<h2>Static Linking</h2>
<p>If you want to keep things simple by only having a few files to 
deploy, i.e. a stand-alone executable with the associated compiler 
specific DLLs, then you must build everything statically.</p>
<a name="building-qt-statically"></a>
<h3>Building Qt Statically</h3>
<p>Before we can build our application we must make sure that Qt is 
built statically. To do this, go to a command prompt and type the 
following:</p>
<pre class="highlightedCode brush: cpp"> cd C:\path\to\Qt
 configure -static &lt;any other options you need&gt;</pre>
<p>Remember to specify any other options you need, such as data base drivers, as arguments to <tt>configure</tt>. Once <tt>configure</tt> has finished, type the following:</p>
<pre class="highlightedCode brush: cpp"> nmake sub-src</pre>
<p>This will build Qt statically. Note that unlike with a dynamic build,
 building Qt statically will result in libraries without version 
numbers; e.g. <tt>QtCore4.lib</tt> will be <tt>QtCore.lib</tt>. Also, we have used <tt>nmake</tt> in all the examples, but if you use MinGW you must use <tt>mingw32-make</tt> instead.</p>
<p><b>Note:</b> If you later need to reconfigure and rebuild Qt from the
 same location, ensure that all traces of the previous configuration are
 removed by entering the build directory and typing <tt>nmake distclean</tt> before running <tt>configure</tt> again.</p>
<a name="linking-the-application-to-the-static-version-of-qt"></a>
<h3>Linking the Application to the Static Version of Qt</h3>
<p>Once Qt has finished building we can build the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> application. First we must go into the directory that contains the application:</p>
<pre class="highlightedCode brush: cpp"> cd examples\tools\plugandpaint</pre>
<p>We must then run <tt>qmake</tt> to create a new makefile for the application, and do a clean build to create the statically linked executable:</p>
<pre class="highlightedCode brush: cpp"> nmake clean
 qmake -config release
 nmake</pre>
<p>You probably want to link against the release libraries, and you can specify this when invoking <tt>qmake</tt>. Now, provided that everything compiled and linked without any errors, we should have a <tt>plugandpaint.exe</tt>
 file that is ready for deployment. One easy way to check that the 
application really can be run stand-alone is to copy it to a machine 
that doesn't have Qt or any Qt applications installed, and run it on 
that machine.</p>
<p>Remember that if your application depends on compiler specific 
libraries, these must still be redistributed along with your 
application. You can check which libraries your application is linking 
against by using the <tt>depends</tt> tool. For more information, see the <a href="#application-dependencies">Application Dependencies</a> section.</p>
<p>The <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> example consists of several components: The application itself (<a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a>), and the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaintplugins-basictools.html">Basic Tools</a> and <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaintplugins-extrafilters.html">Extra Filters</a>
 plugins. Since we cannot deploy plugins using the static linking 
approach, the application we have prepared is incomplete. It will run, 
but the functionality will be disabled due to the missing plugins. To 
deploy plugin-based applications we should use the shared library 
approach.</p>
<a name="shared-libraries"></a>
<h2>Shared Libraries</h2>
<p>We have two challenges when deploying the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a>
 application using the shared libraries approach: The Qt runtime has to 
be correctly redistributed along with the application executable, and 
the plugins have to be installed in the correct location on the target 
system so that the application can find them.</p>
<a name="building-qt-as-a-shared-library"></a>
<h3>Building Qt as a Shared Library</h3>
<p>We assume that you already have installed Qt as a shared library, which is the default when installing Qt, in the <tt>C:\path\to\Qt</tt> directory. For more information on how to build Qt, see the <a href="http://doc.qt.nokia.com/4.7/installation.html">Installation</a> documentation.</p>
<a name="linking-the-application-to-qt-as-a-shared-library"></a>
<h3>Linking the Application to Qt as a Shared Library</h3>
<p>After ensuring that Qt is built as a shared library, we can build the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> application. First, we must go into the directory that contains the application:</p>
<pre class="highlightedCode brush: cpp"> cd examples\tools\plugandpaint</pre>
<p>Now run <tt>qmake</tt> to create a new makefile for the application, and do a clean build to create the dynamically linked executable:</p>
<pre class="highlightedCode brush: cpp"> nmake clean
 qmake -config release
 nmake</pre>
<p>This builds the core application, the following will build the plugins:</p>
<pre class="highlightedCode brush: cpp"> cd ..\plugandpaintplugins
 nmake clean
 qmake -config release
 nmake</pre>
<p>If everything compiled and linked without any errors, we will get a <tt>plugandpaint.exe</tt> executable and the <tt>pnp_basictools.dll</tt> and <tt>pnp_extrafilters.dll</tt> plugin files.</p>
<a name="creating-the-application-package"></a>
<h3>Creating the Application Package</h3>
<p>To deploy the application, we must make sure that we copy the 
relevant Qt DLL (corresponding to the Qt modules used in the 
application) as well as the executable to the same directory in the <tt>release</tt> subdirectory.</p>
<p>Remember that if your application depends on compiler specific 
libraries, these must be redistributed along with your application. You 
can check which libraries your application is linking against by using 
the <tt>depends</tt> tool. For more information, see the <a href="#application-dependencies">Application Dependencies</a> section.</p>
<p>We'll cover the plugins shortly, but first we'll check that the 
application will work in a deployed environment: Either copy the 
executable and the Qt DLLs to a machine that doesn't have Qt or any Qt 
applications installed, or if you want to test on the build machine, 
ensure that the machine doesn't have Qt in its environment.</p>
<p>If the application starts without any problems, then we have successfully made a dynamically linked version of the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> application. But the application's functionality will still be missing since we have not yet deployed the associated plugins.</p>
<p>Plugins work differently to normal DLLs, so we can't just copy them 
into the same directory as our application's executable as we did with 
the Qt DLLs. When looking for plugins, the application searches in a <tt>plugins</tt> subdirectory inside the directory of the application executable.</p>
<p>So to make the plugins available to our application, we have to create the <tt>plugins</tt> subdirectory and copy over the relevant DLLs:</p>
<pre class="highlightedCode brush: cpp"> plugins\pnp_basictools.dll
 plugins\pnp_extrafilters.dll</pre>
<p>An archive distributing all the Qt DLLs and application specific plugins required to run the <a href="http://doc.qt.nokia.com/4.7/tools-plugandpaint.html">Plug &amp; Paint</a> application, would have to include the following files:</p>
<table class="generic">
 <thead><tr class="qt-style topAlign"><th>Component</th><th colspan="2" rowspan=" 1">File Name</th></tr></thead>
<tbody><tr class="odd topAlign"><td><p>The executable</p></td><td colspan="2" rowspan=" 1"><p><tt>plugandpaint.exe</tt></p></td></tr>
<tr class="even topAlign"><td><p>The Basic Tools plugin</p></td><td colspan="2" rowspan=" 1"><p><tt>plugins\pnp_basictools.dll</tt></p></td></tr>
<tr class="odd topAlign"><td><p>The ExtraFilters plugin</p></td><td colspan="2" rowspan=" 1"><p><tt>plugins\pnp_extrafilters.dll</tt></p></td></tr>
<tr class="even topAlign"><td><p>The Qt Core module</p></td><td colspan="2" rowspan=" 1"><p><tt>qtcore4.dll</tt></p></td></tr>
<tr class="odd topAlign"><td><p>The Qt GUI module</p></td><td colspan="2" rowspan=" 1"><p><tt>qtgui4.dll</tt></p></td></tr>
</tbody></table>
<p>In addition, the archive must contain the following compiler specific libraries depending on your version of Visual Studio:</p>
<table class="generic">
 <thead><tr class="qt-style topAlign"><th></th><th>VC++ 6.0</th><th>VC++ 7.1 (2003)</th><th>VC++ 8.0 (2005)</th><th>VC++ 9.0 (2008)</th></tr></thead>
<tbody><tr class="odd topAlign"><td><p>The C run-time</p></td><td><p><tt>msvcrt.dll</tt></p></td><td><p><tt>msvcr71.dll</tt></p></td><td><p><tt>msvcr80.dll</tt></p></td><td><p><tt>msvcr90.dll</tt></p></td></tr>
<tr class="even topAlign"><td><p>The C++ run-time</p></td><td><p><tt>msvcp60.dll</tt></p></td><td><p><tt>msvcp71.dll</tt></p></td><td><p><tt>msvcp80.dll</tt></p></td><td><p><tt>msvcp90.dll</tt></p></td></tr>
</tbody></table>
<p>To verify that the application now can be successfully deployed, you 
can extract this archive on a machine without Qt and without any 
compiler installed, and try to run it.</p>
<p>An alternative to putting the plugins in the plugins subdirectory is 
to add a custom search path when you start your application using <a href="http://doc.qt.nokia.com/4.7/qcoreapplication.html#addLibraryPath">QApplication::addLibraryPath</a>() or <a href="http://doc.qt.nokia.com/4.7/qcoreapplication.html#setLibraryPaths">QApplication::setLibraryPaths</a>().</p>
<pre class="highlightedCode brush: cpp"> qApp-&gt;addLibraryPath("C:\some\other\path");</pre>
<p>One benefit of using plugins is that they can easily be made available to a whole family of applications.</p>
<p>It's often most convenient to add the path in the application's <tt>main()</tt> function, right after the <a href="http://doc.qt.nokia.com/4.7/qapplication.html">QApplication</a> object is created. Once the path is added, the application will search it for plugins, in addition to looking in the <tt>plugins</tt> subdirectory in the application's own directory. Any number of additional paths can be added.</p>
<a name="visual-studio-2005-onwards"></a>
<h3>Visual Studio 2005 Onwards</h3>
<p>When deploying an application compiled with Visual Studio 2005 onwards, there are some additional steps to be taken.</p>
<p>First, we need to copy the manifest file created when linking the 
application. This manifest file contains information about the 
application's dependencies on side-by-side assemblies, such as the 
runtime libraries.</p>
<p>The manifest file needs to be copied into the <b>same</b> folder as 
the application executable. You do not need to copy the manifest files 
for shared libraries (DLLs), since they are not used.</p>
<p>If the shared library has dependencies that are different from the 
application using it, the manifest file needs to be embedded into the 
DLL binary. Since Qt 4.1.3, the follwoing <tt>CONFIG</tt> options are available for embedding manifests:</p>
<pre class="highlightedCode brush: cpp"> embed_manifest_dll
 embed_manifest_exe</pre>
<p>To use the options, add</p>
<pre class="highlightedCode brush: cpp"> CONFIG += embed_manifest_exe</pre>
<p>to your .pro file. The <tt>embed_manifest_dll</tt> option is enabled by default.</p>
<p>You can find more information about manifest files and side-by-side assemblies at the <a href="http://msdn.microsoft.com/en-us/library/aa376307.aspx">MSDN website</a>.</p>
<p>The correct way to include the runtime libraries with your 
application is to ensure that they are installed on the end-user's 
system.</p>
<p>To install the runtime libraries on the end-user's system, you need 
to include the appropriate Visual C++ Redistributable Package (VCRedist)
 executable with your application and ensure that it is executed when 
the user installs your application.</p>
<p>For example, on an 32-bit x86-based system, you would include the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE">vcredist_x86.exe</a> executable. The <a href="http://www.microsoft.com/downloads/details.aspx?familyid=526BF4A7-44E6-4A91-B328-A4594ADB70E5">vcredist_IA64.exe</a> and <a href="http://www.microsoft.com/downloads/details.aspx?familyid=90548130-4468-4BBC-9673-D6ACABD5D13B">vcredist_x64.exe</a> executables provide the appropriate libraries for the IA64 and 64-bit x86 architectures, respectively.</p>
<p><b>Note:</b> The application you ship must be compiled with exactly 
the same compiler version against the same C runtime version. This 
prevents deploying errors caused by different versions of the C runtime 
libraries.</p>
<a name="visual-studio-2008-and-manual-installs"></a>
<h3>Visual Studio 2008 And Manual Installs</h3>
<p>As well as the above details for VS 2005 and onwards, Visual Studio 
2008 applications may have problems when deploying manually, say to a 
USB stick.</p>
<p>The recommended procedure is to configure Qt with the <tt>-plugin-manifests</tt> option using the 'configure' tool. Then follow the <a href="http://msdn.microsoft.com/en-us/library/ms235291%28VS.80%29.aspx">guidelines</a> for manually deploying private assemblies.</p>
<p>In brief the steps are</p>
<ol type="1">
<li>create a folder structure on the development computer that will 
match the target USB stick directory structure, for example '\app' and 
for your dlls, '\app\lib'.</li>
<li>on the development computer, from the appropriate 'redist' folder 
copy over Microsoft.VC80.CRT and Microsoft.VC80.MFC to the directories 
'\app' and '\app\lib' on the development PC.</li>
<li>xcopy the \app folder to the target USB stick.</li>
</ol>
<p>Your application should now run. Also be aware that even with a 
service pack installed the Windows DLLs that are linked to will be the 
defaults. See the information on <a href="http://msdn.microsoft.com/en-us/library/cc664727.aspx">how to select the appropriate target DLLs</a>.</p>
<a name="application-dependencies"></a>
<h2>Application Dependencies</h2>
<a name="additional-libraries"></a>
<h3>Additional Libraries</h3>
<p>Depending on configuration, compiler specific libraries must be 
redistributed along with your application. You can check which libraries
 your application is linking against by using the <a href="http://www.dependencywalker.com/">Dependency Walker</a> tool. All you need to do is to run it like this:</p>
<pre class="highlightedCode brush: cpp"> depends &lt;application executable&gt;</pre>
<p>This will provide a list of the libraries that your application depends on and other information.</p>
<p class="centerAlign"><img src="deployment-windows_files/deployment-windows-depends.png"></p><p>When looking at the release build of the Plug &amp; Paint executable (<tt>plugandpaint.exe</tt>) with the <tt>depends</tt> tool, the tool lists the following immediate dependencies to non-system libraries:</p>
<table class="generic">
 <thead><tr class="qt-style topAlign"><th>Qt</th><th>VC++ 6.0</th><th>VC++ 7.1 (2003)</th><th>VC++ 8.0 (2005)</th><th>MinGW</th></tr></thead>
<tbody><tr class="odd topAlign"><td><p></p><ul>
<li>QTCORE4.DLL - The <a href="http://doc.qt.nokia.com/4.7/qtcore.html">QtCore</a> runtime</li>
<li>QTGUI4.DLL - The <a href="http://doc.qt.nokia.com/4.7/qtgui.html">QtGui</a> runtime</li>
</ul>
</td><td><p></p><ul>
<li>MSVCRT.DLL - The C runtime</li>
<li>MSVCP60.DLL - The C++ runtime (only when STL is installed)</li>
</ul>
</td><td><p></p><ul>
<li>MSVCR71.DLL - The C runtime</li>
<li>MSVCP71.DLL - The C++ runtime (only when STL is installed)</li>
</ul>
</td><td><p></p><ul>
<li>MSVCR80.DLL - The C runtime</li>
<li>MSVCP80.DLL - The C++ runtime (only when STL is installed)</li>
</ul>
</td><td><p></p><ul>
<li>MINGWM10.DLL - The MinGW run-time</li>
</ul>
</td></tr>
</tbody></table>
<p>When looking at the plugin DLLs the exact same dependencies are listed.</p>
<a name="qt-plugins"></a>
<h3>Qt Plugins</h3>
<p>Your application may also depend on one or more Qt plugins, such as 
the JPEG image format plugin or a SQL driver plugin. Be sure to 
distribute any Qt plugins that you need with your application, and note 
that each type of plugin should be located within a specific 
subdirectory (such as <tt>imageformats</tt> or <tt>sqldrivers</tt>) within your distribution directory, as described below.</p>
<p><b>Note:</b> If you are deploying an application that uses <a href="http://doc.qt.nokia.com/4.7/qtwebkit.html">QtWebKit</a>
 to display HTML pages from the World Wide Web, you should include all 
text codec plugins to support as many HTML encodings possible.</p>
<p>The search path for Qt plugins is hard-coded into the <a href="http://doc.qt.nokia.com/4.7/qtcore.html">QtCore</a>
 library. By default, the plugins subdirectory of the Qt installation is
 the first plugin search path. However, pre-determined paths like the 
default one have certain disadvantages. For example, they may not exist 
on the target machine. For that reason, you need to examine various 
alternatives to make sure that the Qt plugins are found:</p>
<ul>
<li><a href="http://doc.qt.nokia.com/4.7/qt-conf.html">Using <tt>qt.conf</tt></a>. This approach is the recommended if you have executables in different places sharing the same plugins.</li>
<li>Using <a href="http://doc.qt.nokia.com/4.7/qcoreapplication.html#addLibraryPath">QApplication::addLibraryPath</a>() or <a href="http://doc.qt.nokia.com/4.7/qcoreapplication.html#setLibraryPaths">QApplication::setLibraryPaths</a>(). This approach is recommended if you only have one executable that will use the plugin.</li>
<li>Using a third party installation utility to change the hard-coded paths in the <a href="http://doc.qt.nokia.com/4.7/qtcore.html">QtCore</a> library.</li>
</ul>
<p>If you add a custom path using QApplication::addLibraryPath it could look like this:</p>
<pre class="highlightedCode brush: cpp"> qApp-&gt;addLibraryPath("C:/customPath/plugins");</pre>
<p>Then <a href="http://doc.qt.nokia.com/4.7/qapplication.html#qApp">qApp</a>-&gt;libraryPaths() would return something like this:</p>
<p>"C:/customPath/plugins " "C:/Qt/4.7.0/plugins" "E:/myApplication/directory/"</p>
<p>The executable will look for the plugins in these directories and the same order as the <a href="http://doc.qt.nokia.com/4.7/qstringlist.html">QStringList</a> returned by <a href="http://doc.qt.nokia.com/4.7/qapplication.html#qApp">qApp</a>-&gt;libraryPaths(). The newly added path is prepended to the <a href="http://doc.qt.nokia.com/4.7/qapplication.html#qApp">qApp</a>-&gt;libraryPaths() which means that it will be searched through first. However, if you use <a href="http://doc.qt.nokia.com/4.7/qapplication.html#qApp">qApp</a>-&gt;setLibraryPaths(), you will be able to determend which paths and in which order they will be searched.</p>
<p>The <a href="http://doc.qt.nokia.com/4.7/plugins-howto.html">How to Create Qt Plugins</a> document outlines the issues you need to pay attention to when building and deploying plugins for Qt applications.</p>
<a name="related-third-party-resources"></a>
<h2>Related Third Party Resources</h2>
<ul>
<li><a href="http://silmor.de/29">Cross compiling Qt/Win Apps on Linux</a> covers the process of cross-compiling Windows applications on Linux.</li>
<li><a href="http://divided-mind.blogspot.com/2007/09/cross-compiling-qt4win-on-linux.html">Cross-compiling Qt4/Win on Linux</a> provides another Linux-to-Windows cross-compilation guide.</li>
</ul>
</div>
<!-- @@@deployment-windows.html -->
<p>
</p>
        <div class="feedback t_button">
          [+] Documentation Feedback</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">©</acronym> 2008-2010 Nokia Corporation and/or its
      subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide.</p>
    <p>
      All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
    <br>
    <p>
      Licensees holding valid Qt Commercial licenses may use this 
document in accordance with the      Qt Commercial License Agreement 
provided with the Software or, alternatively, in accordance      with 
the terms contained in a written agreement between you and Nokia.</p>
    <p>
      Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
      Free Documentation License version 1.3</a>
      as published by the Free Software Foundation.</p>
  </div>
  <div id="feedbackBox">
      <div id="feedcloseX" class="feedclose t_button">X</div>
    <form id="feedform" action="http://doc.qt.nokia.com/docFeedbck/feedback.php" method="get">
      <p id="noteHead">Thank you for giving your feedback.</p> <p class="note">Make sure it is related to this specific page. For more general bugs and 
      requests, please use the <a href="http://bugreports.qt.nokia.com/secure/Dashboard.jspa">Qt Bug Tracker</a>.</p>
      <p><textarea id="feedbox" name="feedText" rows="5" cols="40"></textarea></p>
      <p><input id="feedsubmit" class="feedclose" name="feedback" type="submit"></p>
    <input id="feedUrl" name="feedUrl" value="http://doc.qt.nokia.com/4.7/deployment-windows.html" style="display: none;"><input id="pageVal" name="pageVal" value="Qt 4.7.0: Deploying an Application on Windows" style="display: none;"></form>
  </div>
  <div id="blurpage">
  </div>
  <script src="deployment-windows_files/functions.js" type="text/javascript"></script>
  <!-- <script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4457116-5']);
  _gaq.push(['_trackPageview']);
  (function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  </script> -->
<div style="position: absolute; display: none; z-index: 9999;" id="livemargins_control"><img src="deployment-windows_files/monitor-background-horizontal.png" style="position: absolute; left: -77px; top: -5px;" width="77" height="5">	<img src="deployment-windows_files/monitor-background-vertical.png" style="position: absolute; left: 0pt; top: -5px;">	<img id="monitor-play-button" src="deployment-windows_files/monitor-play-button.png" onmouseover="this.style.opacity=1" onmouseout="this.style.opacity=0.5" style="position: absolute; left: 1px; top: 0pt; opacity: 0.5; cursor: pointer;"></div></body></html>